Sumo Competition Services

  

The Sumo Competition Services provide a simulation environment which hosts sumo competitions as well as a sample sumo player service which can be used in the simulation environment and with physical robots. 

 

The sumo competition takes place in a round ring.  The inner part of the ring is a non-reflective black surface while the outer part of the ring is brightly colored and reflective.  Two robots are placed within the ring and must remain within the ring.  A match consists of three rounds which are each 60 seconds long.  A round ends when one robot goes outside of the ring and a point is awarded to the other robot.  The point is awarded even if the robot was not pushed out of the ring.  The robot with the most points at the end of the match wins.  If the round finishes with neither robot leaving the ring, no points are awarded.

The services are used with iRobot Create robots with an on-board CE computer and a mounted webcam.  The robots have a differential drive which allows them to move forward or backward at any angle and also to swivel in place.  The robots have left and right bumper sensors to sense contact with another robot and IR sensors on the bottom to detect a change in the IR reflectivity under the robot.  The different reflectivity of the outer part of the ring allows the robots to sense when they are about to leave the ring.

Installation

There are four sets of files required to run the simulation:

1)      Media files for all the new meshes and materials for the sumo ring and the robots.  These are placed under the store\media directory.

2)      Manifest and configuration files for the referee and two sumo players. These are placed under samples\config.

3)      Source files and VS project for a sample sumo player service. These will be copied under samples\simulation\competitions\SimulatedSumoServices\SumoPlayer.

4)    SimulatedSumoReferee assemblies. These are placed in the \bin directory. Source to the referee is currently not available.

Download the executable and run it after accepting the EULA. This will install the above files and fix up the projects for your RDS installation.

Run the sumo referee service using one of these two methods:

            a.  Run from Visual Studio. 

            b.  Run from the Microsoft Robotics Developer Studio Command line. 

 

When the referee service starts, a sumo ring will be displayed in the simulation window.  If you ran the sumoplayer service from Visual Studio, the first player will already be selected.  Select the second player using the drop-down menu in the referee window.  You may notice an error message in the dsshost console window when a sumo player service starts if the referee service is already running.  This is because the sumo player service attempts to start the referee service.  You can ignore this error.

 

 

SimulatedSumoReferee Service

The Referee service is provided and maintained by Microsoft.  It allows you to select player services to participate in the match and then it runs each of the three rounds, keeping track of the score and declaring a winner or tie at the end.

When the Referee Service starts, it presents a dropdown list of available players.  If you have recently compiled a new player service and it does not appear in the list, select Refresh from the list and the referee will refresh the Contract Cache which lists all available services.  You can select any of the listed players or you can select None to allow a single robot to run by itself.  This can be useful when debugging the wander and edge-avoidance modes of your sumo player service.  At the start of each round, the robots are positioned behind the brown marker lines in the ring with a random orientation.  When the round timer starts, the referee service pushes the Play button on each simulated robot.  The robots wait for 5 seconds before moving.  If a robot fails to wait for five seconds in the physical match, it will lose the round.  A round ends when one of the robots goes off the edge of the ring or when the time expires.  At that point, the referee service pushes the Advance button on each robot which signals to the sumo player service that the round is over.  After three rounds, the referee will announce the winner and a new match can be started with new opponents.

Because the simulation engine and both sumo player services and their associated services all run on the same machine, it is important that the machine have a reasonable, recent graphics card and adequate performance

 

The Sample Sumo Player Service

The Sample Sumo Player service provides an example of how a service might interpret sensor data coming from the robot and drive the robot to implement a strategy.  The service gives an example of the necessary components required for a sumo player service but it is not intended to be an example of the best possible sumo strategy.  We leave that exercise up to you!

The first method to be called in the service is Start().  It calls ConnectWithRobot() which connects with the hardware iRobotLite service on a physical device and with the SimulatedIRobotLite service in the simulation case.  Because the interface on these services is the same, the same sumo player can be used in the simulation environment and on the physical sumo ring.

The main execution routine in the sumo player service is TimerHandler().  This method is called about 20 times per second to make a decision about the action to perform next.  If a frame is available from the camera, it is processed and the result is used to help make the decision.  Frames may only be available around once every second.  The sample sumo player service defaults to wander mode where it tries to find its opponent.  When its vision processing algorithm indicates that the other robot has been located, it switches to tracking mode.

At any time, a sensor on the robot may change its state and the corresponding handler is called.  This may happen when a bumper is pressed or when one or more of the IR sensors on the bottom of the robot indicate that the reflectivity under the robot has changed.  The robot must usually immediately change its mode to respond to this sensor data.  Failure to respond quickly to an IR sensor notification, for example, can mean that the robot goes out of the ring before it can respond.

Again, neither the strategy nor the image processing code is intended to be an example of the best possible way to do this.  We anticipate that you can implement something much better!

 

How to Make Your Own Sumo Player Service

You can examine the sample sumo player service and then build your own from scratch using DssNewService.  However, many people will find it easier to clone the sample service into a new service which can then be easily modified. 

Each sumo player service must have a unique contract identifier.  Follow these steps to build your own sumo player service.  In these steps, we will build a sumo player service called “Sitting Duck”. 

1)      Open a DSS Command Prompt window by selecting that option from the start menu.

2)    Type the following on the command line.  Substitute your robot name for "SittingDuck".  Your robot name should contain only letters and digits with no spaces.

MakeSumoPlayer /name:"SittingDuck" /force:true

This will create a new sumo player service by copying, modifying, and renaming the sample sumoplayer sources into a new directory.  The utility prints the location of the new directory when it is finished:

C:\Microsoft Robotics Developer Studio (1.5)>MakeSumoPlayer /name:"SittingDuck" /force:true
* The new sumo player project is in: C:\Microsoft Robotics Developer Studio (1.5)\samples\simulation\competitions\simulatedsumoservices\SittingDuck
* Total time: 0.1 seconds.

A new directory called SittingDuck is created which contains the new service and its associated files.

2)      Open the new project that was created for you.  In this example it is C:\Microsoft Robotics Developer Studio (1.5)\samples\simulation\competitions\simulatedsumoservices\SittingDuck\SittingDuck.csproj

3)    Press F5 to start the sumo referee service with your new player as player1.  You can customize your new player by changing the image in resources\PlayerImage.bmp but don't change the size or color depth of the image.

Two project files are generated.  The SittingDuck.csproj project file is used to build a sumoplayer service that will run with the simulator on a PC.  The CF.SittingDuck.csproj project is used to build a sumo player service that will run on a sumo robot.  Care should be taken to keep these two projects synchronized when new references or new files are added.

 

Debugging your Sumo Player Service

There are a few tips that can make debugging your new sumo player service a little easier. 

  1. You can add debug messages to your new sumo player service that will help you track what it is doing.  Look at the LogInfo() calls as an example.  When you are testing your final service, you should minimize the amount of debug messages that are printed.
  2. One of the options on the player selection dropdown control in the Sumo Referee Service window is 'None'.  You can select your service as the first player and 'None' as the second player to see how your robot navigates around the ring when there is no competitor.  This is a great way to tune your search mode and to make sure that your player can stay inside the ring reliably. 
  3. The edit mode in the simulator can also help you change and discover the entity state associated with your robot.  Press F5 to put the simulator into edit mode.  By default, this turns off the physics engine so your robots will stop moving.  You can re-enable physics, if desired, from the Physics menu.  Once you are in edit mode, select one of the two robots listed in the upper-right pane.  The state of the robot will be displayed in the lower-left  pane.  Look for information about what the sensors are returning.  For example, you can see the state of both bumpers and the values being returned by the IR sensors.  While the robot is selected, you can press the control key to highlight it.  If you then click on the position or rotation properties, you can move or rotate the robot around the ring by dragging the left mouse button.  You can expand the robot to see its child entities.  Click on the camera to see its properties.  You can modify the UpdateInterval property on the camera to change how often it sends a new frame to your robot.
  4. You can view the match from the perspective of your robot by pressing the F8 button.  This will toggle between the main camera and the camera on each of the robot players.  You can view multiple cameras simultaneously by opening  a browser window while the match is running and navigating to http://localhost:50000.  Click on the Service Directory in the left-hand pane and then click on one of the webcam services.  This will display a web page which allows you to view the stream of frames coming from the camera associated with the service.

Compiling your service for Windows CE and deploying to the hardware

These instructions tell you how to compile your service for Windows CE and update your project so that all necessary files are deployed to the robot.  These instruction assume that your sumo player project is called SittingDuck.  Please substitute your actual sumo player service name wherever you see "SittingDuck"

  1. Open the Compact Framework project for your service in Visual Studio.  The project file is cf.SittingDuck.csproj.

  2. Select the ICOP_eBox2300_CE600_SDK device.

  3. Build the project and verify that there are no compilation errors.

  4. Add links to the following two files in your project by doing the following:

  5. right-click on the cf.SittingDuck project and select Add Existing Item...

  6. change to this directory: \Microsoft Robotics Developer Studio (1.5)\bin\CF

  7. select cf.sittingduck.*.*.proxy.dll

  8. also select cf.sittingduck.*.*.transform.dll

  9. Don't press the Add button but press the small arrow at the right of the Add button and select Add As Link

  10. Right click on each of the new files in the SittingDuck project and select Properties

  11. Set the Build Action property to Content and the Copy to Output Directory property to Copy Always

  12. Right-click on the cf.SittingDuck project and select properties.  Select the Debug tab.

  13. Select Start External Program and type the following for the program:  \Program Files\msrs\bin\cf.dsshost.exe

  14. Stop all running services on the robot.

  15. Deploy your project to the robot by right-clicking on the cf.SittingDuck project and selecting Deploy

  16. Run your service on the Robot by pressing F5

 

Questions and Support

If you have questions about the Sumo Competition Service or would like to report a bug, the RDS simulation forum is the best place to go.  You can find it at:

http://forums.microsoft.com/MSDN/default.aspx?ForumGroupID=383&SiteID=1

Happy Sumo-ing!